//
//  THTaskHallCell.m
//  YJB
//
//  Created by YJB on 2016/12/16.
//  Copyright © 2016年 YJB. All rights reserved.
//

#import "THTaskCell.h"
#import "masonry.h"
#import "THTaskModel.h"

@interface THTaskCell ()
@property(nonatomic,strong)UILabel  *titleLab;
@property(nonatomic,strong)UILabel  *award;
@property(nonatomic,strong)UILabel  *vipAward;
@end

NSString *const taskCellID = @"taskCellID";
@implementation THTaskCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.backgroundColor = kUIColorFromRGB(0xfff5f0);
    }
    return self;
}

-(UILabel *)titleLab
{
    if (_titleLab == nil)
    {
        _titleLab = [[UILabel alloc]init];
        _titleLab.backgroundColor = [UIColor clearColor];
        _titleLab.textAlignment = NSTextAlignmentLeft;
        _titleLab.font = FONT(15);
        _titleLab.numberOfLines = 0;
        _titleLab.textColor = kUIColorFromRGB(0x333333);
        [self addSubview:_titleLab];
        [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
            make.left.mas_equalTo(12);
            make.width.mas_equalTo(IPHONE_W - 18 * GRIDW - 12);
        }];
    }
    return _titleLab;
}

-(UILabel *)award
{
    if (_award == nil)
    {
        _award = [[UILabel alloc]init];
        _award.backgroundColor = [UIColor clearColor];
        _award.font = FONT(15);
        _award.textAlignment = NSTextAlignmentCenter;
        _award.numberOfLines = 0;
        _award.textColor = kUIColorFromRGB(0x333333);
        [self addSubview:_award];
        [_award mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
            make.left.mas_equalTo(self.titleLab.mas_right);
            make.width.mas_equalTo(9 * GRIDW);
        }];
    }
    return _award;
}

-(UILabel *)vipAward
{
    if (_vipAward == nil)
    {
        _vipAward = [[UILabel alloc]init];
        _vipAward.backgroundColor = [UIColor clearColor];
        _vipAward.font = FONT(17);
        _vipAward.textAlignment = NSTextAlignmentCenter;
        _vipAward.numberOfLines = 0;
        _vipAward.textColor = kUIColorFromRGB(0xff730a);
        [self addSubview:_vipAward];
        [_vipAward mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
            make.left.mas_equalTo(self.award.mas_right);
            make.width.mas_equalTo(9 * GRIDW);
        }];
    }
    return _vipAward;
}

-(void)setTask:(THTaskModel *)task
{
    self.titleLab.text = task.title;
    if (task.award.length != 0)//任务大厅
    {
        self.award.text = [task.award stringByAppendingString:@"金币"];
        self.vipAward.text = [task.vipAward stringByAppendingString:@"金币"];
    }else if(task.num.length != 0)//我发布的
    {
        self.award.text = [NSString stringWithFormat:@"%@/%@",task.num,task.spareNum];
        self.vipAward.text = [NSString stringWithFormat:@"%@/%@",task.checkNum,task.pendnum];
    }else if(task.publishid.length != 0)//我参与的
    {
        self.award.text = task.publishName;
        self.vipAward.text = task.uprice;
    }
}


@end
